<template>
  <view class="detail">
    <view class="title">{{article.title}}</view>
    <view class="info">
      <view class="author">编辑: {{article.author}}</view>
      <view class="time">{{article.posttime}}</view>
    </view>
    <view class="content">
      <rich-text :nodes="article.content"></rich-text>
    </view>
    <view class="description">
      版权申明
    </view>
  </view>
</template>

<script>
  import {handleHtmlImg} from '../../utils/textutil.js'
  import {parseTime} from '../../utils/dateutil.js'
  export default {
    data() {
      return {
        id: null,
        cid: null,
        article:{
          
        }
      };
    },
    methods: {
      getDetailById() {
        uni.request({
          url:`https://ku.qingnian8.com/dataApi/news/detail.php?cid=${this.cid}&id=${this.id}`,
          success: (res) => {
            res.data.content = handleHtmlImg(res.data.content)
            res.data.posttime = parseTime(res.data.posttime)
            this.article = res.data
          }
        })
      }

    },
    onLoad(option) {
      this.id = option.id
      this.cid = option.cid
      this.getDetailById()
    }
  }
</script>

<style lang="scss" scoped>
  .detail {
    padding: 30rpx;

    .title {
      font-size: 38rpx;
      color: #333;
    }

    .info {
      background: #f6f6f6;
      padding: 20rpx 10rpx;
      font-size: 25rpx;
      color: #999;
      display: flex;
      justify-content: space-between;
      margin: 40rpx 0;
    }

    .content {
      padding-bottom: 50rpx;
      // h5处理图片问题
      // /deep/ img{
      //   width: 100%;
      // }
    }

    .description {
      background: #fef0f0;
      font-size: 36rpx;
      padding: 20rpx;
      color: #f89898;
      line-height: 1.8em;
    }
  }
</style>
